package com.bree.erp.entity;

import java.util.Collection;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.NamedQueries;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

@NamedQueries({
	@NamedQuery(name = Project.QUERY_FIND_PROJECT_BY_CODE, 
				query = "SELECT p FROM Project p WHERE p.code = :code"),
	@NamedQuery(name = Project.QUERY_SELECT_ALL_PROJECT, 
				query = "SELECT p FROM Project p")
})
@Entity
public class Project {
	
	public static final String QUERY_FIND_PROJECT_BY_CODE = "findProjectByCode";
	public static final String QUERY_SELECT_ALL_PROJECT = "selectAllProject";
			
	@Id 
	@GeneratedValue(strategy=GenerationType.AUTO)
	private long id;
	
	private String code;
	private String description;
	
	@OneToMany(mappedBy="project")
	private Collection<PurchaseRequisition> purchaseRequisitions;
	
	@OneToOne
	private Warehouse defaultWarehouse;
	
	/**
	 * @return the id
	 */
	public long getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(long id) {
		this.id = id;
	}
	/**
	 * @return the code
	 */
	public String getCode() {
		return code;
	}
	/**
	 * @param code the code to set
	 */
	public void setCode(String code) {
		this.code = code;
	}
	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}
	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	/**
	 * @return the purchaseRequisitions
	 */
	public Collection<PurchaseRequisition> getPurchaseRequisitions() {
		return purchaseRequisitions;
	}
	/**
	 * @param purchaseRequisitions the purchaseRequisitions to set
	 */
	public void setPurchaseRequisitions(
			Collection<PurchaseRequisition> purchaseRequisitions) {
		this.purchaseRequisitions = purchaseRequisitions;
	}
	/**
	 * @return the defaultWarehouse
	 */
	public Warehouse getDefaultWarehouse() {
		return defaultWarehouse;
	}
	/**
	 * @param defaultWarehouse the defaultWarehouse to set
	 */
	public void setDefaultWarehouse(Warehouse defaultWarehouse) {
		this.defaultWarehouse = defaultWarehouse;
	}
}
